// import getUserInfo from '../js/hybrid-api/get-user-info.js'
// import scanCode from '../js/hybrid-api/scan-code.js'
// import showToast from '../js/hybrid-api/show-toast.js'
// import showConfirm from '../js/hybrid-api/show-confirm.js'
// import showAlert from '../js/hybrid-api/show-alert.js'
// import configHeader from '../js/hybrid-api/config-header.js'
// import refreshUserInfo from '../js/hybrid-api/refresh-user-Info.js'
// import closeApp from '../js/hybrid-api/close-app.js'
// let hybridApi = {
//   configHeader,
//   getUserInfo,
//   scanCode,
//   showToast,
//   showAlert,
//   showConfirm,
//   refreshUserInfo,
//   closeApp
// }
import Vue from 'vue'
import camelCase from 'lodash/camelCase'
const requireComponent = require.context(
  // 其组件目录的相对路径
  '../js/hybrid-api',
  // 是否查询其子目录里的vue文件
  true, /\.js/
)
const hybridApi = {};
requireComponent.keys().forEach(fileName => {
  // 获取组件配置
  const hybridConfig = requireComponent(fileName)
  let i = fileName.lastIndexOf("/");
  // 获取组件的 小驼峰 命名
  const componentName = camelCase(
    // 剥去文件名开头的 `./` 和结尾的扩展名
    fileName.slice(i + 1, -3).replace(/^\.\/(.*)\.\w+$/, '$1')
  )
  hybridApi[componentName] = hybridConfig.default || hybridConfig
})


if (process.env.NODE_ENV === 'production') {
  //build
} else {
  //dev
  for (var apiName in hybridApi) {
    hybridApi[apiName] = function () {
      console.log("调用原生接口")
    }
  }
}

Vue.prototype.$hybridApi=hybridApi;
